import { ref } from 'vue';
import httpServe from '../global-services/index';

/**
 * 筛选 >> 角色
 * @param hasAllOpt 是否需要 "全选" 这一选项
 * @returns
 */
export const useRoleSelects = (hasAllOpt = false) => {
	const roleOpts = ref<TsSelectOption[]>([]);
	async function setOptions() {
		const res: any = await httpServe.getHttp('/system/roles/selectList')();

		if (res.code === 0) {
			roleOpts.value = res.data;
			if (hasAllOpt) {
				roleOpts.value.unshift({ label: '全选', value: '' });
			}
		}
	}
	setOptions();
	return { roleOpts };
};
